<?php
/**
 * Created by PhpStorm.
 * User: wangwenfan
 * Date: 2018/7/31
 * Time: 10:29.
 */

namespace App\Admin\Controllers;

use App\Models\Login\TestAllowAccount;
use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;

class WhiteListController extends Controller
{
    use ModelForm;

    /**首页
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('game.gm_tool'));
            $content->description(trans('game.white_list'));
            $content->body($this->grid());
        });
    }

    protected function grid()
    {
        $grid = Admin::grid(TestAllowAccount::class, function (Grid $grid) {
            $grid->account(trans('game.account'));
            $grid->disableExport();
            $grid->disableFilter();
            $grid->actions(function ($actions) use ($grid) {
                $actions->disableEdit();
            });
        });

        return $grid;
    }

    /**
     * Create interface.
     *
     * @return Content
     */
    public function create()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('game.gm_tool'));
            $content->description(trans('admin.new'));

            $content->body($this->form());
        });
    }

    protected function form()
    {
        return Admin::form(TestAllowAccount::class, function (Form $form) {
            $form->text('account', trans('game.account'))->rules('required');
        });
    }
}
